/**
 * MineAdmin is committed to providing solutions for quickly building web applications
 * Please view the LICENSE file that was distributed with this source code,
 * For the full copyright and license information.
 * Thank you very much for using MineAdmin.
 *
 * @Author X.Mo<root@imoi.cn>
 * @Link   https://github.com/mineadmin
 */

import type { MaSearchItem } from "@mineadmin/search";
import { rdOrganizeAreaStandStatusDictData } from "./common.tsx";
import MaDictSelect from "@/components/ma-dict-picker/ma-dict-select.vue";
import MaDictRadio from "@/components/ma-dict-picker/ma-dict-radio.vue";
import MaRemoteSelect from "@/components/ma-remote-select/index.vue";
import { page as getAreaList } from "@/plugins/ai-warning/organization/api/rdOrganizeArea.ts";

export default function getSearchItems(t: any): MaSearchItem[] {
  return [
    {
      label: "所属工区",
      prop: "area_id",
      render: () => MaRemoteSelect,
      renderProps: {
        api: getAreaList,
        apiParams: {
          page: 1,
          pageSize: 1000,
        },
        dataHandle: (response: any) => {
          if (response.code === 200 && response.data && response.data.list) {
            return response.data.list.map((area: any) => ({
              label: area.name,
              value: area.id,
            }));
          }
          return [];
        },
        placeholder: "请选择所属工区",
        filterable: true,
        clearable: true,
      },
    },
    {
      label: "站点名称",
      prop: "name",
      render: "input",
      renderProps: { placeholder: t("form.pleaseInput", { msg: "站点名称" }) },
    },
    {
      label: "简称",
      prop: "abbr",
      render: "input",
      renderProps: { placeholder: t("form.pleaseInput", { msg: "简称" }) },
    },
    {
      label: "状态",
      prop: "status",
      render: "select",
      renderProps: {
        placeholder: "请选择状态",
        clearable: true,
        options: rdOrganizeAreaStandStatusDictData().map((item) => ({
          label: item.label,
          value: item.value,
        })),
      },
    },
  ];
}
